<?php

namespace App\Http\Controllers\Admin\Config\Record;

use Illuminate\Http\Request;
use App\Http\Controllers\AdminController;

use Storage;
class SystemLogController extends AdminController
{
     /**
     * 获取列表数据
     * @return [type] [description]
     */
    function getLists(Request $request){
    	$logs = Storage::disk('logs')->files('/');
    	$data['total'] = count($logs);
    	if($data['total']>0){
    		foreach ($logs as $log) {
    			$result [] = array('name'=>$log);
    		}
    		$data['result'] = $result;
    	}
    	$this->ajaxJson(0,'',$data);
    }

    /**
     * 文件查看
     * @param  Request $request [description]
     * @return [type]           [description]
     */
    function fileView(Request $request){
        $name = $request->input('name');
        if(!$name){
            exit;
        }
    	$contents = Storage::disk('logs')->get($name);
        echo '<pre>';
        print($contents);
        echo '</pre>';
    }

    /**
     * 删除文件
     * @param  Request $request [description]
     * @return [type]           [description]
     */
    function delFile(Request $request){
    	Storage::disk('logs')->delete($request->input('name'));
    	$this->ajaxJson(0,'删除成功');
    }
}
